/**
 * 
 */
package org.dse.analysis.dict;

/**
 * This class is used to indicate the word type in the tree-structured
 * dictionary. The dictionary tree contains three types of word. The normal word
 * indicates the word which is used independently and mostly, the suffix word is
 * only used at the tail of a word, and the count word is used to indicate the
 * word behind number words in Chinese.
 * 
 * Other words is stored in hash set because it is short and the number is
 * little.
 * 
 * @author zhangchen
 * 
 */
public class WordType {

	// 3 types of word, using number to represent
	private static final int NORMWORD = 1;
	private static final int SUFFIX = 0x10;
	private static final int COUNT = 0x100;

	private int wordTypeValue;

	/**
	 * The default constructor.
	 */
	public WordType() {
		this.wordTypeValue = 0;
	}

	private WordType(int wordTypeValue) {
		this.wordTypeValue = wordTypeValue;
	}

	/**
	 * Give a word a word type. The word type can be merged into its original
	 * type.
	 * 
	 * @param wordType
	 *            the merged type
	 */
	public void addWordType(WordType wordType) {
		wordTypeValue = wordTypeValue | wordType.wordTypeValue;
	}

	/**
	 * Judge the word type is normal word.
	 * 
	 * @return a boolean value to show whether it is normal type
	 */
	public boolean isNormWord() {
		return (wordTypeValue & NORMWORD) > 0;
	}

	/**
	 * Judge the word type is suffix word.
	 * 
	 * @return a boolean value to show whether it is suffix type
	 */
	public boolean isSuffix() {
		return (wordTypeValue & SUFFIX) > 0;
	}

	/**
	 * Judge the word type is count word.
	 * 
	 * @return a boolean value to show whether it is count type
	 */
	public boolean isCount() {
		return (wordTypeValue & COUNT) > 0;
	}

	/** the normal type of word constant */
	public static final WordType WT_NORMWORD = new WordType(NORMWORD);

	/** the suffix type of word constant */
	public static final WordType WT_SUFFIX = new WordType(SUFFIX);

	/** the count type of word constant */
	public static final WordType WT_COUNT = new WordType(COUNT);
}